/*
============================================================================
 Name        : $(Basename)Server.h
 Author      : $(Author)
 Version     :
 Copyright   : $(Copyright)
 Description : $(Basename)Server.
============================================================================
*/

#ifndef __C$(BASENAME)SERVER_H__
#define __C$(BASENAME)SERVER_H__

#include <e32base.h>
#include "$(Basename)Server.pan"

const TUid K$(Basename)ServerUid = { $(serverUid) };

_LIT(K$(Basename)ServerName, "$(Basename)Server");
_LIT(K$(Basename)ServerFileName, "$(Basename)Server");
_LIT(K$(Basename)ServerSemaphoreName, "$(Basename)ServerSemaphore");

const TInt K$(Basename)ServMajorVersionNumber = 0;
const TInt K$(Basename)ServMinorVersionNumber = 1;
const TInt K$(Basename)ServBuildVersionNumber = 2;

enum T$(Basename)ServRequests
	{
	E$(Basename)ServRequestTime,
	E$(Basename)ServCancelRequestTime
	};

enum T$(Basename)ServRequestCompletes
	{
	E$(Basename)ServRequestTimeComplete = 1
	};

class C$(Basename)Server : public CServer2, public MBeating
	{

	public :

		static C$(Basename)Server* NewL();
		static C$(Basename)Server* NewLC();
		virtual ~C$(Basename)Server();

	public:

		static TInt EntryPoint(TAny* aStarted);

		void IncrementSessions();
		void DecrementSessions();
		void WaitForTickL();

	public: // Functions from base classes

		void Beat();
		void Synchronize();

	protected: // Functions from base classes

		TInt RunError(TInt aError);

	private: // Constructors and destructors

		C$(Basename)Server(TInt aPriority);
		void ConstructL();

	private: // New methods

		static void PanicClient(const RMessage2& aMessage, T$(Basename)ServPanic aPanic);
		static void PanicServer(T$(Basename)ServPanic aPanic);

		static void ThreadMainL();

		void SendTimeToSessions();

	private: // Functions from base classes

		CSession2* NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const;

	private: // Data

		TInt iSessionCount;
		CHeartbeat* iExampleHeartbeat;

	};
#endif // __C$(BASENAME)SERVER_H__
